package jia.temp;

import java.net.MalformedURLException;
import jia.core.GameStateManager;
import jia.core.InputProcessor;
import jia.core.Module;
import jia.core.state.BasicGameStateManager;
import jia.game.TestGame;
import jia.game.AreaViewport;
import jia.game.Viewport;

import javax.swing.*;
import java.awt.*;

// ====================================================

/**
 * @author Alec Lanter <p/> TODO: Add key intercepts
 */
public class AreaViewportTest extends JFrame {
    
    protected GameStateManager mgr = new BasicGameStateManager();
    protected Viewport viewport;
    protected InputProcessor inputProc;
    
    // ====================================================
    /**
     * @param args
     */
    public static void main(String[] args) throws MalformedURLException {
        new AreaViewportTest().setVisible(true);
    }
    
    // ====================================================
    /**
     */
    public AreaViewportTest() throws MalformedURLException {
        UIManager.put("ScrollBarUI", "jia.plaf.JIAScrollBarUI");
        setSize(400, 400);
        setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE);
        setResizable(false);
        setTitle("Area Viewport Test");
        TestGame test = new TestGame();
        Module myMod = test.getTestModule();
        mgr.getPlayerState().setCurrentModule(myMod);
        mgr.getPlayerState().setPosition(myMod.getDefaultEntryPoint().getEntryPosition());
        mgr.getPlayerState().setFacing(myMod.getDefaultEntryPoint().getEntryFacing());
        viewport = new AreaViewport();
        viewport.updateGameState(mgr);
        JScrollPane scroller = new JScrollPane((AreaViewport) viewport);
        getContentPane().add(scroller);
        
    }
    
    // ====================================================
    /**
     * @see java.awt.Component#paint(java.awt.Graphics)
     */
    public void paint(Graphics g) {
        super.paint(g);
        viewport.updateGameState(mgr);
    }
    
}
